package com.manopservice.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.manopservice.dao.CarTypeDAO;
import com.manopservice.model.CarType;

@Service("carTypeService")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class CarTypeServiceImpl implements CarTypeService {

	@Autowired
	private CarTypeDAO carTypeDAO;

	public CarTypeServiceImpl() {
	}

	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void saveCarType(CarType carType) {
		carTypeDAO.save(carType);
	}
	
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
	public void deleteCarType(int id) {
		carTypeDAO.delete(id);
		
	}

	public List<CarType> listCarTypes() {
		return carTypeDAO.findAll();
	}

	@Override
	public CarType findCarTypeById(int id) {
		return carTypeDAO.findById(id);
	}

}
